$(function(){
	$("#publishBtn").click(publish);
});

function publish() {
	$("#publishModal").modal("hide");
	var title = $("#recipient-name").val();
	var content = $("#message-text").val();
	var param = {
		title: title,
		content: content,
	}
	param = JSON.stringify(param);
	$.ajax({
		type: "post",
		url: CONTEXT_PATH + "/discuss/add",
		dataType: "json",
		contentType : 'application/json',
		data: param,
		success: function (res) {
			// 在提示框中显示返回信息
			$("#hintBody").text(res.msg);
			// 显示提示框
			$("#hintModal").modal("show");
			// 2秒后,自动隐藏提示框
			setTimeout(function(){
				$("#hintModal").modal("hide");
				// 刷新页面
				if (res.code === 200) {
					window.location.reload();
				}
			}, 2000);
		}
	})
}